// 导入ex模块
const express = require('express')
let Mock = require('mockjs');
const { noticeList } = require('./notice_data')
// 获取区域数据
//2.创建路由对象
const router = express.Router()
// restfull的风格 用的是params
router.get('/noticeList', (request, response) => {
  // console.info('get方法获取到了', request.query)
  // console.info('get方法获取到了', request.params)
  let back = {
    "total": noticeList.length,
    "rows": noticeList,
    "code": 200,
    "msg": "查询成功"
  }
  response.send(back)
})
// 根据id 获取房屋数据
router.get('/notice/:id', (request, response) => {
  let notice_id = request.params.id
  let notice = noticeList.find((item) => {
    return item.id ==notice_id
  })
  let back = {
    "data": notice,
    "code": 200,
    "msg": "查询成功"
  }
  response.send(back)
})
//向外导出路由对象
module.exports = router